<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

$_LangPath = "oldnews";
include_once(__Admin_Path."/logincheck_nodb.php");
include_once(__Language_Path."/selectlanguage_admin.php");

if(!$_SESSION["Admin_Info"] -> ForceSetCommunication && $_SESSION["Admin_Info"] -> MemberGroup == 2){
	include_once(__DBConnect_File);
	$strSQL = "select * from `bet_Authentication` where UserID = ".$_SESSION["Admin_Info"] -> ID." and `isCheck` = 1";
	if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
		$GLOBALS["errormessage"] = "Find Data Error!!";
		$GLOBALS["errorhidden"] = "\nError: ".PMA_mysql_error($$_Conn).",\nLinue:".__LINE__.",\nPage:".__FILE__;
		ErrMsgOutputHTML("Error1", "", 1);
	}
	if(PMA_mysql_num_rows($RS) == 0){
		$_SESSION["Admin_Info"] -> ForceSetCommunication = true;
		header("Location: /k_admin/UserCredit/UserCommunicate.php");
		exit();
	}
}
$_SESSION["Admin_Info"] -> ForceSetCommunication = true;

$arrSiteID = array(
	1 => 1,	
	2 => 2,	11 => 2,	
	3 => 3,	12 => 3,	
	4 => 4,	13 => 4,	
	5 => 5,	14 => 5
);
$intUserGroup = $_SESSION["Admin_Info"] -> MemberGroup;
if($intUserGroup > 30){
	$intSiteID = 30;
}else{
	$intSiteID = $arrSiteID[$intUserGroup];
}
@include_once(__Common_Path."/marquee/Marquee".$intSiteID."_".$_intLang.".php");

$fp = @file(__Admintemplate_Path."/oldnews.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

while(list($k, $v) = each($_strOldNews)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

//非管理階層，不能看到系統資訊
if($_SESSION["Admin_Info"] -> MemberGroup < 30){
	$fp = preg_replace("/<!-- SystemNews@bof \/\/-->.+<!-- SystemNews@eof \/\/-->/s", $strCon, $fp);
}
preg_match("/<!--@ System News Start @\/\/-->(.+)<!--@ System News End @\/\/-->/s", $fp, $d);
$strSystem = $d[1];
preg_match("/<!--@ Important News Start @\/\/-->(.+)<!--@ Important News End @\/\/-->/s", $fp, $d);
$strImportant = $d[1];
preg_match("/<!--@ Common News Start @\/\/-->(.+)<!--@ Common News End @\/\/-->/s", $fp, $d);
$strCommon = $d[1];

$strCon1 = "";
$strCon2 = "";
if(sizeof($Marquee) > 0){
	foreach($Marquee as $arrMq){
		if(!preg_match("/,".$_SESSION["Admin_Info"] -> SpGroup.",/", ",".$arrMq["SpGroup"].",") && $_SESSION["Admin_Info"] -> MemberGroup < 20)continue;
		if($arrMq["isSystem"] == "1"){
			$strTmp = str_replace("{ShowTime}", $arrMq["OnDate"], $strSystem);
			$strTmp = str_replace("{ShowNews}", " ".addslashes($arrMq["Content"])." ", $strTmp); 
			$strConSystem .= $strTmp;

		}elseif($arrMq["isPopup"] == "1"){
			$strTmp = str_replace("{ShowTime}", $arrMq["OnDate"], $strImportant);
			$strTmp = str_replace("{ShowNews}", " ".addslashes($arrMq["Content"])." ", $strTmp); 
			$strConImportant .= $strTmp;

		}else{
			$strTmp = str_replace("{ShowTime}", $arrMq["OnDate"], $strCommon);
			$strTmp = str_replace("{ShowNews}", " ".addslashes($arrMq["Content"])." ", $strTmp);
			$strConCommon .= $strTmp;
		}
	}
}
$fp = preg_replace("/<!--@ System News Start @\/\/-->.+<!--@ System News End @\/\/-->/s", $strConSystem, $fp);
$fp = preg_replace("/<!--@ Important News Start @\/\/-->.+<!--@ Important News End @\/\/-->/s", $strConImportant, $fp);
$fp = preg_replace("/<!--@ Common News Start @\/\/-->.+<!--@ Common News End @\/\/-->/s", $strConCommon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>